package org.mags.rema.control.commons;

import java.io.Serializable;

import org.mags.dao.provider.DataContextImp;
import org.mags.rema.model.provider.EntityProviderFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class EngineContext implements Serializable {
	private ApplicationContext context = null;
	private static EngineContext instance = null;
	private EngineContext(){		
	}
	public static EngineContext getInstance() {
		if(instance==null)
			instance = new EngineContext();
		return instance;
	}
	public ApplicationContext getApplicationContext() {
		if(context==null)
			context = new ClassPathXmlApplicationContext("applicationContext.xml");
		return context;
	}
	public DataContextImp getDataAccess() {
		return (DataContextImp)this.getApplicationContext().getBean("dataAccess");
	}
	public EntityProviderFactory getEntityProviderFactory() {
		return (EntityProviderFactory)this.getDataAccess().getProviderFactory("entity");
	}
}
